
import cloud from '@lafjs/cloud'
import nw from "nw-lafjs";
import {fail, ok} from "@/utils/responseUtil";
const db = cloud.database()
const _ = db.command

export default async function (ctx: FunctionContext) {
  let body = ctx.body
  /**
   * ["1"]
   */
  if ((!nw.util.isArray(body)||body.length===0)){
    return fail("数据格式有误")
  }

  //批量删除即可
  let whereJson = {_id:_.in(body)}

  let count = await nw.db.update({
    dbName:"permission",
    whereJson:whereJson,
    dataJson:{deleted:1}
  })
  if (count===0){
    return fail("删除失败")
  }
  return ok("删除成功")
}
